/**
 * Created by lvlq on 16/3/19.
 */
var Sequelize = require("sequelize");
var sequelize = Util("sequelize");

module.exports = sequelize.define("queue", {
    activityId: {
        type: Sequelize.INTEGER,
        field: "activityId",
        allowNull: false,
        defaultValue: 0
    },
    participantId: {
        type: Sequelize.INTEGER,
        field: "participantId",
        allowNull: false,
        defaultValue: 0
    },
    player: {
        type: Sequelize.INTEGER,
        field: "player",
        allowNull: false,
        defaultValue: 0
    },
    username: {
        type: Sequelize.TEXT,
        field: "username",
        allowNull: false,
        defaultValue: "",
        set: function (val) {
            var b = new Buffer(val);
            var s = b.toString('base64');
            this.setDataValue('username', s);
        }
    },
    clientKey: {
        type: Sequelize.TEXT,
        field: "clientKey",
        allowNull: false,
        defaultValue: ""
    },
    status: {
        type: Sequelize.INTEGER,
        field: "status",
        allowNull: false,
        defaultValue: 0
    },
    points: {
        type: Sequelize.INTEGER,
        field: "points",
        allowNull: false,
        defaultValue: 0
    },
    images: {
        type: Sequelize.TEXT,
        field: "images",
        allowNull: false,
        defaultValue: ""
    },
    videos: {
        type: Sequelize.TEXT,
        field: "videos",
        allowNull: false,
        defaultValue: ""
    }

}, {
    comment: "队列表",
    indexes: [
        {
            fields: ["activityId", 'participantId']
        },
        {
            fields: ["activityId", 'status']
        },
        {
            fields: ["activityId", 'participantId', 'status']
        }
    ]
});